import Mock from 'mockjs'
const Random = Mock.Random;
import {
  urlParams2Obj
} from '@/utils/index.js'
//生成模拟数据：按月汇总订单金额、数量
let orderSumByMonth = [];
for (let i = 1; i <= 12; i++) {
  orderSumByMonth.push({
    month: (i + '').padStart(2, '0'), //'01'、'02'、'03'...
    jsby: Random.integer(1000, 7000),
    xxyz: Random.integer(1000, 7000),
    jycl: Random.integer(1000, 7000),
    tyjs: Random.integer(1000, 7000),
    dzsj: Random.integer(1000, 7000),
  });
}

// 生成模拟API接口
Mock.mock(new RegExp('/home/echars/orderSumByMonth'), 'get', options => {
  const {
    url
  } = options;
  const query = urlParams2Obj(url);
  const {
    year
  } = query;
  const result = {
    code: 1,
    msg: "成功获取:" + year,
    data: orderSumByMonth
  }
  return result;
});


//生成模拟数据：按月汇总评论数量
let orderSumByFamily = [];
for (let i = 1; i <= 12; i++) {
  orderSumByFamily.push({
    month: (i + '').padStart(2, '0'), //'01'、'02'、'03'...
    count: Random.integer(2000, 7000),
  });
}

// 生成模拟API接口
Mock.mock(new RegExp('/home/echars/orderSumByFamily'), 'get', options => {
  const {
    url
  } = options;
  const query = urlParams2Obj(url);
  const {
    year
  } = query;
  const result = {
    code: 1,
    msg: "成功获取:" + year,
    data: orderSumByFamily
  }
  return result;
});